#pragma once
#pragma warning(disable:4996)

#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <fstream>
#include <sstream>
#include <ctime>
#include <Winbase.h>

using namespace std;

#define STRING wstring
#define OFSTREAM wofstream

class CCommLog
{
private:
    OFSTREAM *m_hFileStream;
    CRITICAL_SECTION    m_LogCS;

public:
    static STRING GetCurrentTimeStr();

private:
    static CCommLog *m_pCommLog;

private:
    static wstring s2ws(const string& s)
    {
        const char* _Source = s.c_str();
        size_t _Dsize = MultiByteToWideChar(CP_ACP, 0, _Source, -1, NULL, 0);
        wchar_t *_Dest = new wchar_t[_Dsize];
        MultiByteToWideChar(CP_ACP, 0, _Source, -1, _Dest, _Dsize);
        wstring result = _Dest;
        delete []_Dest;
        return result;
    }

public:
    static CCommLog* GetLogger();
    static void Init(STRING logFileName);

public:
    //void Debug(STRING string);
    //void Info(STRING string);
    //void Error(STRING string);
    //void Fatal(STRING string);
    void Log(wstring string);
    void Log(string string);
    //bool isDebugEnable();

private:
    CCommLog(STRING fileName);

public:
    ~CCommLog(void);
};


